//加载组件
layui.config({
    base: './js/'  //导入xm-select.js
}).extend({
    xmSelect: 'xm-select'
}).use(['xmSelect', 'layer','form'], function() {
    var xmSelect = layui.xmSelect,
        layer = layui.layer,
        form = layui.form;


//角色信息回显
    let id = GetQueryString('sectionId');
    if(id){
        let url ="/logisticsSection/selectOne";
        let data ={id:id};
        $.get(url,data,function (resp){
            form.val('example',resp);
        })
    }



    $("#up").on("click",function (){
        $.ajax({
            url:"/logisticsSection/addOrUpdateSection",
            data: {
                sectionId:$("#sectionId").val(),
                sectionName:$("#sectionName").val()
            },
            dataType:'json',//数据类型
            type:'POST',//类型
            timeout:5000,//超时
            success:function(resp){
                parent.layer.msg(resp.mes);//父页面消息提示
                layerClose();//关闭弹窗
            }
        })
    })
    //关闭按钮
    $("#close_btn").on("click", function () {
        layerClose();
    });
})

//在子页面中关闭弹出层
function layerClose(){
    var index= parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}